package easy;

public class CountAndSay {

    public String countAndSay(int n){
        if(n==1) return "1";
        String say = "1";
        for (int i = 1; i < n; i++) {
            String tempSay = say;
            say="";
            int length = tempSay.length();
            int count = 0;
            char c = tempSay.charAt(0);
            for (int j = 0; j < length; j++) {
                char tempC = tempSay.charAt(j);
                if(c==tempC){
                    count++;
                }else{
                    say += count+""+c;
                    c = tempSay.charAt(j);
                    count = 1;
                }
            }
            say += count+""+c;
        }
        return say;
    }


}
